# 21.py
# 迭代器3

class Person:
  def __init__(self):
    self.age = 1

  def __iter__(self):
    self.age = 1
    return self

  def __next__(self):
    self.age += 1
    if self.age >= 6:
      raise StopIteration('stop')
    return self.age

p = Person()

for i in p:
  print(i)
for i in p:
  print(i)

print(p.age)
import collections

from collections.abc import Iterator
print(collections.abc)

# 迭代器
print(isinstance(p, collections.abc.Iterator))
# 这里是 可以迭代的对象，范围是超过迭代器的
print(isinstance(p, collections.abc.Iterable))
  

